package com.huwaiwai.thread.task;

import com.google.common.util.concurrent.FutureCallback;

import java.io.Serializable;
import java.util.List;

/**
 * 并发请求类
 * Created by huweiwei on 2017/4/10.
 */
public class TaskRequest implements Serializable{

    /**
     * 任务数量
     */
    private int taskCount;

    /**
     * 任务列表
     */
    private List<TaskFunction> taskList;

    /**
     * 回调函数
     */
    private FutureCallback futureCallback;

    /**
     * 是否忽略失败
     */
    private boolean ignoreError;

    public TaskRequest(List<TaskFunction> taskList) {
        this(taskList.size(), taskList, null, true);
    }

    public TaskRequest(List<TaskFunction> taskList, boolean ignoreError) {
        this(taskList.size(), taskList, null, ignoreError);
    }

    public TaskRequest(List<TaskFunction> taskList, FutureCallback futureCallback) {
        this(taskList.size(), taskList, futureCallback, true);
    }

    public TaskRequest(List<TaskFunction> taskList, FutureCallback futureCallback, boolean ignoreError) {
        this (taskList.size(), taskList, futureCallback, ignoreError);
    }

    private TaskRequest(int taskCount, List<TaskFunction> taskList, FutureCallback futureCallback, boolean ignoreError) {
        this.taskCount = taskCount;
        this.taskList = taskList;
        this.futureCallback = futureCallback;
        this.ignoreError = ignoreError;
    }

    public int getTaskCount() {
        return taskCount;
    }

    public List<TaskFunction> getTaskList() {
        return taskList;
    }

    public FutureCallback getFutureCallback() {
        return futureCallback;
    }

    public boolean isIgnoreError() {
        return ignoreError;
    }
}
